#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e6+100;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
char str[maxn];
LL pre[maxn],suf[maxn];
LL mod=0;
LL ksm(LL a,LL k){LL res=1;while(k>0){if(k&1) res=res*a%mod;k>>=1;a=a*a%mod;}return res%mod;}
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  cin>>(str+1);
  LL a,b;cin>>a>>b;
  mod=b;
  LL len=strlen(str+1);
  for(LL i=1;i<=len;i++){
     pre[i]=(pre[i-1]*10%a+(str[i]-'0')%a)%a;
  }
  LL cnt=0;
  for(LL i=len;i>=1;i--){
     suf[i]=( ( (str[i]-'0')%b*ksm(10,cnt)%b)%b+suf[i+1]%b )%b;
     cnt++;
  }
    /*
  for(LL i=1;i<=len;i++) cout<<pre[i]<<" ";
  cout<<"\n";
  for(LL i=1;i<=len;i++) cout<<suf[i]<<" ";
  cout<<"\n";
*/
  LL pos1=0;LL pos2=0;bool flag=1;
  for(LL i=1;i<=len;i++){
    if(pre[i]==0&&suf[i+1]==0&&str[i+1]!='0'){
        pos1=i;pos2=i+1;
        flag=0;
        break;
    }
  }
  ///debug(pos1);debug(pos2);
  if(flag==1||pos2==0||pos1==0||pos2>len||pos1>len) cout<<"NO"<<"\n";
  else{
    cout<<"YES"<<"\n";
    for(LL i=1;i<=pos1;i++){
        cout<<str[i];
    }
    cout<<"\n";
    for(LL i=pos2;i<=len;i++){
        cout<<str[i];
    }
    cout<<"\n";
  }
return 0;
}
